package cn.drenal.capcap.controller.forum;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.drenal.capcap.common.Response;
import cn.drenal.capcap.entity.Artwork;
import cn.drenal.capcap.entity.vo.forum.ForumArtworkCardVO;
import cn.drenal.capcap.mapper.ArtworkMapper;
import cn.drenal.capcap.service.ArtworkService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 前台排行榜控制器
 */
@RestController
@RequestMapping("/forum/ranking")
@RequiredArgsConstructor
public class ForumRankingController {

    private final ArtworkService artworkService;

    /**
     * 获取评论数最多的作品排行榜
     *
     * @return 评论数最多的10个作品
     */
    @SaIgnore
    @GetMapping("/most-commented")
    public Response<List<ForumArtworkCardVO>> getMostCommentedArtworks() {
        // 查询评论数最多的10个作品
        List<ForumArtworkCardVO> artworks = artworkService.getTopArtworksByCommentCount(10);
        return Response.success(artworks);
    }

    /**
     * 获取收藏数最多的作品排行榜
     *
     * @return 收藏数最多的10个作品
     */
    @SaIgnore
    @GetMapping("/most-favorited")
    public Response<List<ForumArtworkCardVO>> getMostFavoritedArtworks() {
        // 查询收藏数最多的10个作品
        List<ForumArtworkCardVO> artworks = artworkService.getTopArtworksByFavoriteCount(10);
        return Response.success(artworks);
    }

    /**
     * 获取综合排行榜（评论数+收藏数*10）
     *
     * @return 综合评分最高的10个作品
     */
    @SaIgnore
    @GetMapping("/comprehensive")
    public Response<List<ForumArtworkCardVO>> getComprehensiveRanking() {
        // 查询综合评分最高的10个作品
        List<ForumArtworkCardVO> artworks = artworkService.getTopArtworksByComprehensiveScore(10);
        return Response.success(artworks);
    }
}